package com.vken.blog.service.impl;

import java.util.List;

import com.vken.blog.dao.BlogDao;
import com.vken.blog.dao.LinkDao;
import com.vken.blog.model.Link;
import com.vken.blog.service.LinkManager;

public class LinkManagerImpl implements LinkManager {
	private LinkDao linkDao;
	private BlogDao blogDao;

	public void setLinkDao(LinkDao linkDao) {
		this.linkDao = linkDao;
	}

	public void setBlogDao(BlogDao blogDao) {
		this.blogDao = blogDao;
	}

	public void delete(Integer id) {
		linkDao.delete(linkDao.findById(id));
	}

	public Link get(Integer id) {
		return linkDao.findById(id);
	}

	public List<Link> list(Integer id) {
		return linkDao.getLinksByBlogId(id);
	}

	public void update(Link link) {
		linkDao.update(link);
	}

	public void insert(Link link, Integer blogId) {
		link.setBlog(blogDao.findById(blogId));
		linkDao.save(link);
	}
}
